package gp.STL;

import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
//定义标签处理器
public class ClientIPTag extends SimpleTagSupport {
    @Override
    public void doTag() throws JspException, IOException {
        JspContext jspcontext = this.getJspContext();
        PageContext pageContext = (PageContext) jspcontext;
        ServletRequest request = pageContext.getRequest();
        String remoteAddr = request.getRemoteAddr();
        JspWriter writer = pageContext.getOut();
        writer.print(remoteAddr);
    }
}
